<!DOCTYPE html><html lang="en" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>核函数 | Bulua</title><meta name="keywords" content="机器学习"><meta name="author" content="Bulua"><meta name="copyright" content="Bulua"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="核函数K（kernel function）就是指K(x, y) &#x3D; &lt;f(x), f(y)&gt;，其中x和y是n维的输入值，f(·) 是从n维到m维的映射（通常，m&gt;&gt;n）。&lt;x, y&gt;是x和y的内积（inner product）(也称点积（dot product）)。">
<meta property="og:type" content="article">
<meta property="og:title" content="核函数">
<meta property="og:url" content="http://bulua.gitee.io/2021/10/19/Kernel-Function/index.html">
<meta property="og:site_name" content="Bulua">
<meta property="og:description" content="核函数K（kernel function）就是指K(x, y) &#x3D; &lt;f(x), f(y)&gt;，其中x和y是n维的输入值，f(·) 是从n维到m维的映射（通常，m&gt;&gt;n）。&lt;x, y&gt;是x和y的内积（inner product）(也称点积（dot product）)。">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://gitee.com/bulua/bulua_img/raw/master/download.jpg">
<meta property="article:published_time" content="2021-10-19T11:13:40.000Z">
<meta property="article:modified_time" content="2021-10-19T11:39:22.415Z">
<meta property="article:author" content="Bulua">
<meta property="article:tag" content="机器学习">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/bulua/bulua_img/raw/master/download.jpg"><link rel="shortcut icon" href="https://gitee.com/bulua/bulua_img/raw/master/tubiao.jpg"><link rel="canonical" href="http://bulua.gitee.io/2021/10/19/Kernel-Function/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: 'Copy successfully',
    error: 'Copy error',
    noSupport: 'The browser does not support'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: 'days',
  date_suffix: {
    just: 'Just',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"Traditional Chinese Activated Manually","cht_to_chs":"Simplified Chinese Activated Manually","day_to_night":"Dark Mode Activated Manually","night_to_day":"Light Mode Activated Manually","bgLight":"#49b1f5","bgDark":"#121212","position":"top-center"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '核函数',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-10-19 19:39:22'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    document.addEventListener('pjax:complete', detectApple)})(window)</script><link rel="stylesheet" href="/css/custom.css" media="defer" onload="this.media='all'"><meta name="generator" content="Hexo 5.4.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/tubiao.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">8</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">Tags</div><div class="length-num">3</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gitee.com/bulua/bulua_img/raw/master/download.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Bulua</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">核函数</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">Created</span><time class="post-meta-date-created" datetime="2021-10-19T11:13:40.000Z" title="Created 2021-10-19 19:13:40">2021-10-19</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">Updated</span><time class="post-meta-date-updated" datetime="2021-10-19T11:39:22.415Z" title="Updated 2021-10-19 19:39:22">2021-10-19</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="核函数"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">Post View:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p>核函数K（kernel function）就是指K(x, y) = &lt;f(x), f(y)&gt;，其中x和y是n维的输入值，f(·) 是从n维到m维的映射（通常，m&gt;&gt;n）。&lt;x, y&gt;是x和y的内积（inner product）(也称点积（dot product）)。 </p>
<span id="more"></span>

<p>##1、核函数</p>
<p>如果你看了上面的定义还是不够明白，那么我举个小小的栗子：</p>
<p>令 <code>x = (x1, x2, x3, x4); y = (y1, y2, y3, y4)</code>;<br>令 <code>f(x) = (x1x1, x1x2, x1x3, x1x4, x2x1, x2x2, x2x3, x2x4, x3x1, x3x2, x3x3, x3x4, x4x1, x4x2, x4x3, x4x4); f(y)</code>亦然；<br>令核函数 <code>K(x, y) = (&lt;x, y&gt;)^2.</code><br>接下来，让我们带几个简单的数字进去看看是个什么效果：<code>x = (1, 2, 3, 4); y = (5, 6, 7, 8). </code>那么：<br><code>f(x) = ( 1, 2, 3, 4, 2, 4, 6, 8, 3, 6, 9, 12, 4, 8, 12, 16) ;</code><br><code>f(y) = (25, 30, 35, 40, 30, 36, 42, 48, 35, 42, 49, 56, 40, 48, 56, 64) ;</code><br><code>&lt;f(x), f(y)&gt; = 25+60+105+160+60+144+252+384+105+252+441+672+160+384+672+1024 = 4900.</code><br>如果我们用核函数呢？<br><code>K(x, y) = (5+12+21+32)^2 = 70^2 = 4900. </code></p>
<p>所以现在你看出来了吧，kernel其实就是帮我们省去在高维空间里进行繁琐计算的“简便运算法”。甚至，它能解决<strong>无限维空间</strong>无法计算的问题！因为有时f(·)会把n维空间映射到无限维空间去。 </p>
<p><strong>核函数和映射没有关系。</strong>核函数只是用来计算映射到高维空间之后的内积的一种简便方法。</p>
<p>一般英文文献对<code>Kernel</code>有两种提法，一是<code>Kernel Function</code>，二是<code>Kernel Trick</code>。从<code>Trick</code>一词中就可以看出，这只是一种运算技巧而已，不涉及什么高深莫测的东西。</p>
<p>##2、分割不可分数据集的方法</p>
<p> 我们如果想进行原本就线性不可分的数据集进行分割 ，有两种方法：</p>
<ul>
<li>容忍错误分类，即引入<code>Soft Margin</code>； </li>
<li>可以对<code>Input Space</code>做<code>Feature Expansion</code>，把数据集映射到高维中去，形成了<code>Feature Space </code>；</li>
</ul>
<p>我们<strong>几乎可以认为</strong>（引用Caltech的课堂用语“<strong>We are safe but not certain</strong>”）原本在低维中线性不可分的数据集在足够高的维度中存在线性可分的超平面。 </p>
<h2 id="3、核方法"><a href="#3、核方法" class="headerlink" title="3、核方法"></a>3、核方法</h2><p>围绕选项二，那么我们所做的就是要在<code>Feature Space</code>套用原本在线性可分情况下的<code>Input Space</code>中使用过的优化方法，来找到那个<code>Maximaizing Margin</code>的超平面。原理机制一模一样，是二次规划，唯一不同是代入数据的不同，我们需要代入<img src= "" data-lazy-src="https://www.zhihu.com/equation?tex=%5Cphi(x_i)" alt="[公式]">而不是<img src= "" data-lazy-src="https://www.zhihu.com/equation?tex=x_i" alt="[公式]">。这时（在假设我们已知了如何选取<code>mapping</code>之后）才有了核函数的概念。</p>
<p>具体<code>Trick</code>的意义，就是简化计算二次规划中间的一步内积计算。也即中间步骤有一步必须求得<img src= "" data-lazy-src="https://www.zhihu.com/equation?tex=%5Cphi(x_i)%27%5Cphi(x_j)" alt="[公式]">，而我们可以定义核函数<img src= "" data-lazy-src="https://www.zhihu.com/equation?tex=K(x_i,x_j)=%5Cphi(x_i)%27%5Cphi(x_j)" alt="[公式]">，使得我们在不需要显式计算每一个<img src= "" data-lazy-src="https://www.zhihu.com/equation?tex=%5Cphi(x_i)" alt="[公式]">、甚至不需要知道<img src= "" data-lazy-src="https://www.zhihu.com/equation?tex=%5Cphi(%5Ccdot+)" alt="[公式]">长什么样的情况下，直接求出<img src= "" data-lazy-src="https://www.zhihu.com/equation?tex=%5Cphi(x_i)%27%5Cphi(x_j)" alt="[公式]">的值来。</p>
<p>也就是说，核函数、内积、相似度这三个词是等价的。因为<code>inner product</code>其实就是一种<code>similarity</code>的度量。核函数和映射是无关的。</p>
<p>但为什么这么多的认知中核函数是一种映射呢。一来这两件事一般先后进行，所以常常被混为一谈。二来就像前面所述，核函数让人们不需要知道<img src= "" data-lazy-src="https://www.zhihu.com/equation?tex=%5Cphi(%5Ccdot+)" alt="[公式]"></p>
<h2 id="总结一下"><a href="#总结一下" class="headerlink" title="总结一下"></a>总结一下</h2><p> 整个<code>story</code>可以这么说：那些搞<code>svm，ridge regression</code>的人，发现自己的算法对数据集的效果不好，他们认为这可能是因为数据集线性不可分。另外他们发现他们搞出的式子里，出现的都是两个数据点的内积。他们想，我们要是把原始数据集映射到高维可能就线性可分啦，但是这可是内积啊，而且怎么找映射函数呢？这时候<code>Mercer Theorem</code>出现了，简直就是黑暗中的一缕阳光啊！好的，那就构造一个<code>kernel function</code>吧，根据<code>Mercer Theorem</code>，那些原始维度的内积转换到高维内积只需要把数据点带进核函数就<code>ok</code>啦。这不就简单了？结果在数据集上居然很好！！！然后这种方法就有很多时髦名称了。你<code>follow</code>了么？</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">Author: </span><span class="post-copyright-info"><a href="mailto:undefined">Bulua</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">Link: </span><span class="post-copyright-info"><a href="http://bulua.gitee.io/2021/10/19/Kernel-Function/">http://bulua.gitee.io/2021/10/19/Kernel-Function/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">Copyright Notice: </span><span class="post-copyright-info">All articles in this blog are licensed under <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> unless stating additionally.</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">机器学习</a></div><div class="post_share"><div class="social-share" data-image="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2021/11/15/PCA/"><img class="prev-cover" src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">Previous Post</div><div class="prev_info">PCA</div></div></a></div><div class="next-post pull-right"><a href="/2021/10/12/svm-xia/"><img class="next-cover" src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">Next Post</div><div class="next_info">支持向量机（下）</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> Related Articles</span></div><div class="relatedPosts-list"><div><a href="/2021/10/11/Logistic-Regression/" title="Logistic-Regression"><img class="cover" src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-10-11</div><div class="title">Logistic-Regression</div></div></a></div><div><a href="/2021/11/15/PCA/" title="PCA"><img class="cover" src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-11-15</div><div class="title">PCA</div></div></a></div><div><a href="/2021/11/15/LDA/" title="LDA"><img class="cover" src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-11-15</div><div class="title">LDA</div></div></a></div><div><a href="/2021/10/12/svm-shang/" title="支持向量机（上）"><img class="cover" src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-10-12</div><div class="title">支持向量机（上）</div></div></a></div><div><a href="/2021/10/12/svm-xia/" title="支持向量机（下）"><img class="cover" src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-10-12</div><div class="title">支持向量机（下）</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> Comment</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/tubiao.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Bulua</div><div class="author-info__description">No matter how far you may fly, never forget where you come from.</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">8</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">Tags</div><div class="length-num">3</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/Bulua" target="_blank" title="Github"><i class="fab fa-github"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>Announcement</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>Catalog</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E6%A0%B8%E6%96%B9%E6%B3%95"><span class="toc-number">1.</span> <span class="toc-text">3、核方法</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%80%BB%E7%BB%93%E4%B8%80%E4%B8%8B"><span class="toc-number">2.</span> <span class="toc-text">总结一下</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>Recent Post</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/11/15/LDA/" title="LDA"><img src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="LDA"/></a><div class="content"><a class="title" href="/2021/11/15/LDA/" title="LDA">LDA</a><time datetime="2021-11-15T12:54:12.000Z" title="Created 2021-11-15 20:54:12">2021-11-15</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/11/15/PCA/" title="PCA"><img src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="PCA"/></a><div class="content"><a class="title" href="/2021/11/15/PCA/" title="PCA">PCA</a><time datetime="2021-11-15T12:34:48.000Z" title="Created 2021-11-15 20:34:48">2021-11-15</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/10/19/Kernel-Function/" title="核函数"><img src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="核函数"/></a><div class="content"><a class="title" href="/2021/10/19/Kernel-Function/" title="核函数">核函数</a><time datetime="2021-10-19T11:13:40.000Z" title="Created 2021-10-19 19:13:40">2021-10-19</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/10/12/svm-xia/" title="支持向量机（下）"><img src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="支持向量机（下）"/></a><div class="content"><a class="title" href="/2021/10/12/svm-xia/" title="支持向量机（下）">支持向量机（下）</a><time datetime="2021-10-12T00:31:00.000Z" title="Created 2021-10-12 08:31:00">2021-10-12</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/10/12/svm-shang/" title="支持向量机（上）"><img src= "" data-lazy-src="https://gitee.com/bulua/bulua_img/raw/master/download.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="支持向量机（上）"/></a><div class="content"><a class="title" href="/2021/10/12/svm-shang/" title="支持向量机（上）">支持向量机（上）</a><time datetime="2021-10-12T00:30:53.000Z" title="Created 2021-10-12 08:30:53">2021-10-12</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2021  <i id="heartbeat" class="fa fas fa-heartbeat"></i> Bulua</div></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/HCLonely/images@master/others/heartbeat.min.css"></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="Read Mode"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="Switch Between Traditional Chinese And Simplified Chinese">繁</button><button id="darkmode" type="button" title="Switch Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between single-column and double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="Table Of Contents"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="Scroll To Comments"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="Back To Top"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><div class="js-pjax"><script>function loadValine () {
  function initValine () {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: 'K7ke6VBNMaIjRIWWht9uCbsT-gzGzoHsz',
      appKey: 'rl09GFl8gOiYw6OxIIIuOzur',
      placeholder: 'Please leave your footprints',
      avatar: 'monsterid',
      meta: 'nick,mail,link'.split(','),
      pageSize: '10',
      lang: 'en',
      recordIP: false,
      serverURLs: '',
      emojiCDN: '',
      emojiMaps: "",
      enableQQ: true,
      path: window.location.pathname,
      requiredFields: ["nick,mail"],
      visitor: false
    }, null))
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !true) {
  if (true) btf.loadComment(document.getElementById('vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script></div><div class="aplayer no-destroy" data-id="186016" data-server="netease" data-type="song" data-fixed="true" data-mini="true" data-listFolded="false" data-order="random" data-preload="none" data-autoplay=true muted></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="true" data-click="true"></script><script defer="defer" id="fluttering_ribbon" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config-diff',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.removeEventListener('scroll', window.tocScrollFn)
  window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>